home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / IO::Handle.Z / IO::Handle
Encoding:
Text File  |  1998-10-28  |  7.8 KB  |  265 lines

  1.  
  2.  
  3.  
  4.      IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       IO::Handle - supply object methods for I/O handles
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           use IO::Handle;
  13.  
  14.           $fh = new    IO::Handle;
  15.           if ($fh->fdopen(fileno(STDIN),"r")) {
  16.           print    $fh->getline;
  17.           $fh->close;
  18.           }
  19.  
  20.           $fh = new    IO::Handle;
  21.           if ($fh->fdopen(fileno(STDOUT),"w")) {
  22.           $fh->print("Some text\n");
  23.           }
  24.  
  25.           use IO::Handle '_IOLBF';
  26.           $fh->setvbuf($buffer_var,    _IOLBF,    1024);
  27.  
  28.           undef $fh;       # automatically closes the file if it's open
  29.  
  30.           autoflush    STDOUT 1;
  31.  
  32.  
  33.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  34.       IO::Handle is    the base class for all other IO    handle
  35.       classes. It is not intended that objects of IO::Handle would
  36.       be created directly, but instead IO::Handle is inherited
  37.       from by several other    classes    in the IO hierarchy.
  38.  
  39.       If you are reading this documentation, looking for a
  40.       replacement for the FileHandle package, then I suggest you
  41.       read the documentation for IO::File
  42.  
  43.       A IO::Handle object is a reference to    a symbol (see the
  44.       Symbol package)
  45.  
  46.      CCCCOOOONNNNSSSSTTTTRRRRUUUUCCCCTTTTOOOORRRR
  47.       new ()
  48.           Creates a    new IO::Handle object.
  49.  
  50.       new_from_fd (    FD, MODE )
  51.           Creates a    IO::Handle like    new does.  It requires two
  52.           parameters, which    are passed to the method fdopen; if
  53.           the fdopen fails,    the object is destroyed. Otherwise, it
  54.           is returned to the caller.
  55.  
  56.      MMMMEEEETTTTHHHHOOOODDDDSSSS
  57.       See the _p_e_r_l_f_u_n_c manpage for complete    descriptions of    each
  58.       of the following supported IO::Handle    methods, which are
  59.       just front ends for the corresponding    built-in functions:
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))
  71.  
  72.  
  73.  
  74.           close
  75.           fileno
  76.           getc
  77.           eof
  78.           read
  79.           truncate
  80.           stat
  81.           print
  82.           printf
  83.           sysread
  84.           syswrite
  85.  
  86.       See the _p_e_r_l_v_a_r manpage for complete descriptions of each of
  87.       the following    supported IO::Handle methods:
  88.  
  89.           autoflush
  90.           output_field_separator
  91.           output_record_separator
  92.           input_record_separator
  93.           input_line_number
  94.           format_page_number
  95.           format_lines_per_page
  96.           format_lines_left
  97.           format_name
  98.           format_top_name
  99.           format_line_break_characters
  100.           format_formfeed
  101.           format_write
  102.  
  103.       Furthermore, for doing normal    I/O you    might need these:
  104.  
  105.       $fh->fdopen (    FD, MODE )
  106.            fdopen is like an ordinary open except that its first
  107.            parameter is not    a filename but rather a    file handle
  108.            name, a IO::Handle object, or a file descriptor number.
  109.  
  110.       $fh->opened
  111.            Returns true if the object is currently a valid file
  112.            descriptor.
  113.  
  114.       $fh->getline
  115.            This works like <$fh> described in the section on _I/_O
  116.            _O_p_e_r_a_t_o_r_s in the    _p_e_r_l_o_p manpage except that it's    more
  117.            readable    and can    be safely called in an array context
  118.            but still returns just one line.
  119.  
  120.       $fh->getlines
  121.            This works like <$fh> when called in an array context
  122.            to read all the remaining lines in a file, except that
  123.            it's more readable.  It will also _c_r_o_a_k() if
  124.            accidentally called in a    scalar context.
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))
  137.  
  138.  
  139.  
  140.       $fh->ungetc (    ORD )
  141.            Pushes a    character with the given ordinal value back
  142.            onto the    given handle's input stream.
  143.  
  144.       $fh->write ( BUF, LEN    [, OFFSET }\] )
  145.            This write is like write    found in C, that is it is the
  146.            opposite    of read. The wrapper for the perl write
  147.            function    is called format_write.
  148.  
  149.       $fh->flush
  150.            Flush the given handle's    buffer.
  151.  
  152.       $fh->error
  153.            Returns a true value if the given handle    has
  154.            experienced any errors since it was opened or since the
  155.            last call to clearerr.
  156.  
  157.       $fh->clearerr
  158.            Clear the given handle's    error indicator.
  159.  
  160.       If the C functions _s_e_t_b_u_f() and/or _s_e_t_v_b_u_f() are available,
  161.       then IO::Handle::setbuf and IO::Handle::setvbuf set the
  162.       buffering policy for an IO::Handle.  The calling sequences
  163.       for the Perl functions are the same as their C
  164.       counterparts--including the constants    _IOFBF,    _IOLBF,    and
  165.       _IONBF for _s_e_t_v_b_u_f()--except that the    buffer parameter
  166.       specifies a scalar variable to use as    a buffer.  WARNING: A
  167.       variable used    as a buffer by setbuf or setvbuf must not be
  168.       modified in any way until the    IO::Handle is closed or    setbuf
  169.       or setvbuf is    called again, or memory    corruption may result!
  170.       Note that you    need to    import the constants _IOFBF, _IOLBF,
  171.       and _IONBF explicitly.
  172.  
  173.       Lastly, there    is a special method for    working    under ----TTTT and
  174.       setuid/gid scripts:
  175.  
  176.       $fh->untaint
  177.            Marks the object    as taint-clean,    and as such data read
  178.            from it will also be considered taint-clean. Note that
  179.            this is a very trusting action to take, and appropriate
  180.            consideration for the data source and potential
  181.            vulnerability should be kept in mind.
  182.  
  183.      NNNNOOOOTTTTEEEE
  184.       A IO::Handle object is a GLOB    reference. Some    modules    that
  185.       inherit from IO::Handle may want to keep object related
  186.       variables in the hash    table part of the GLOB.    In an attempt
  187.       to prevent modules trampling on each other I propose the
  188.       that any such    module should prefix its variables with    its
  189.       own name separated by    _'s. For example the IO::Socket    module
  190.       keeps    a timeout variable in 'io_socket_timeout'.
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     IIIIOOOO::::::::HHHHaaaannnnddddlllleeee((((3333))))
  203.  
  204.  
  205.  
  206.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  207.       the _p_e_r_l_f_u_n_c manpage,    the section on _I/_O _O_p_e_r_a_t_o_r_s in    the
  208.       _p_e_r_l_o_p manpage, the _I_O::_F_i_l_e manpage
  209.  
  210.      BBBBUUUUGGGGSSSS
  211.       Due to backwards compatibility, all filehandles resemble
  212.       objects of class IO::Handle, or actually classes derived
  213.       from that class.  They actually aren't.  Which means you
  214.       can't    derive your own    class from IO::Handle and inherit
  215.       those    methods.
  216.  
  217.      HHHHIIIISSSSTTTTOOOORRRRYYYY
  218.       Derived from FileHandle.pm by    Graham Barr <_b_o_d_g@_t_i_u_k._t_i._c_o_m>
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                        (printed 10/23/98)
  262.  
  263.  
  264.  
  265.